package org.jeecg.modules.xl.shengfutong.request;

import cn.hutool.json.JSON;
import cn.hutool.json.JSONUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.RandomStringUtils;
import org.jeecg.modules.xl.shengfutong.config.ShengftConf;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @version 创建时间：2019年7月16日 下午1:43:16
 * @Description 订单退款请求类 
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class OrderRefundRequest  extends BaseRequest{

	/**
	 * 商户号(必填)
	 */
	private String mchId;

	/**
	 * 商户订单号(支付时商户单号)(必填)
	 */
	private String outTradeNo;

	/**
	 * 退款订单号(必填)
	 */
	private String outRefundNo;

	/**
	 * 退款金额(单位：分)(必填)
	 */
	private Integer refundFee;

	/**
	 * 退款原因
	 */
	private String refundDesc;

	/**
	 * 退款通知地址(必填)
	 */
	private String notifyUrl;

	/**
	 * 商户终端信息(JSON字符串)
	 * 示例：{"deviceId":"s001","deviceName":"清河一店"}
	 */
	private String mchMemberInfo;

	/**
	 * 是否返回退款备注，默认false
	 */
	private Boolean returnAttach;

	/**
	 * 附加信息
	 */
	private String attach;

	/**
	 * 随机字符串(必填)
	 */
	private String nonceStr;

	/**
	 * 签名类型(默认RSA)(必填)
	 */
	private String signType;

	/**
	 * 签名(必填)
	 */
	private String sign;
	public static OrderRefundRequest buildOrderRefund(String outTradeNo,String outRefundNo,int refundFee,String refunsDesc){
		OrderRefundRequest request = new OrderRefundRequest();

		request.setMchId(ShengftConf.MCH_ID);
		request.setOutTradeNo(outTradeNo);
		request.setOutRefundNo(outRefundNo);
		request.setRefundFee(refundFee);
		JSON j =JSONUtil.createObj();
		j.putByPath("isComplement","false");
		request.setAttach(j.toString());
		request.setRefundDesc(refunsDesc);
		request.setNotifyUrl("https://sltwxapi.bugless.site:8443/jeecg-boot/htmmp/myorder/sftPayNotifyUrl");
		request.setNonceStr(RandomStringUtils.randomAlphanumeric(32));
		request.setSignType("RSA");
		return request;
	}

}